<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

//Route::get('/','App\Http\Controllers\Admin\HomeController@index');

//Route::get('/','Admin\HomeController@index');
//在laravel回调函数中使用类型约束有2个好处一个是限制了传入这个
Route::get('/','Admin\RouteController@make');

//模块儿管理

//在线教育模块儿
//include 'moduleroute/eduroute.php';


//文章系统

//新增用户路由组
//新增用户路由组
Route::group(['namespace'=>'User'],function (){
    Route::get('login','LoginController@login')->name('login');
    Route::post('login','LoginController@store')->name('login');
    Route::get('logout','LoginController@logout')->name('logout');
    //注册路由
    Route::get('user/register','RegisterController@create')->name('register');
    Route::post('user/register','RegisterController@store')->name('register');
    //重置密码路由
    Route::get('user/resetpassword','ResetPasswordController@index')->name('user.resetpassword');
    Route::post('user/resetpassword','ResetPasswordController@update')->name('user.resetpassword');
});

//公共路由



?>
------------------------------------------下面是最开始的路由信息--------------------------------------------------------
<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

//Route::get('/','App\Http\Controllers\Admin\HomeController@index');

//Route::get('/','Admin\HomeController@index');
//在laravel回调函数中使用类型约束有2个好处一个是限制了传入这个
Route::get('/',function (\App\Models\AdminModule $module){
    //通过下面的代码将最新的模板信息更新到模板表中,下面这行代码没必要每次打开网页的时候都执行,因为首先网站的模板不会频繁更改,其次刚开始的时候我会执行自定义的初始化网站的命令dh-start.在执行这个命令的时候就会自动刷新网站的模板信息,并将第一条自动设置成正在使用的模板,如果在这里再执行下面的这条命令,只会重新刷新网站的模板表,而不会再默认选中第一个模板作为系统的默认模板
//        \App\Models\ContentTemplateModel::loadTemplate();
    //由于 $module->action;获取到的是一个类名@方法名的字符串,可以手动拆分处理,也可以使用app()->call()方法自动解析并执行"类名@方法名"格式的字符串,实例化"@"前面的类,并调用类中"@"后面的方法
    return app()->call($module->action);
});

//模块儿管理
Route::group(['prefix'=>'admin','namespace'=>'Admin','as'=>'admin.'],function (){
    Route::resource('module','ModuleController');
    Route::get('permission','PermissionController@index')->name('permission.index');
    Route::resource('role','RoleController');
    //角色---权限路由设置
    Route::get('role/{role}/permission','RoleController@editpermision')->name('role.permission');
    Route::post('role/{role}/permission','RoleController@updatepermission')->name('role.permission');
    //用户---角色路由设置
    Route::resource('user_role','UserRoleController');
    //系统配置相关路由
    Route::get('config/{name}','ConfigController@edit')->name('config');
    Route::put('config/{name}','ConfigController@update')->name('config');
});

//在线教育模块儿
include 'moduleroute/eduroute.php';


//文章系统
//Route::resource('category','Content\CategoryController');
//Route::resource('article','Content\ArticleController');
//也可以使用路由组(对路由分组的好处一是可以分组管理,而是不同分组下可以使用相同的名字以免冲突)
//路由组中前一个参数是一个数组,里面定义这个路由组的属性相关内容
//路由组中后一个参数是一个closure闭包函数,里面可以放这个路由组中的路由信息
Route::group(['prefix'=>'content','namespace'=>'Content','as'=>'content.'],function (){
    Route::resource('category','CategoryController');
    Route::resource('model','ModelController');
    Route::resource('slide','SlideController');
    Route::resource('articlemodel','ArticleController');
    Route::resource('template','TemplateController');
    Route::get('selectcategory','ArticleController@selectCategory')->name('selectcategory');
    Route::get('template_cache','TemplateController@cache')->name('template.cache');
    Route::get('template/{template}','TemplateController@update')->name('template.update');
    Route::get('article-{article}.html','HomeController@content')->name('home.content');
    Route::get('category-{category}.html','HomeController@category')->name('home.category');
});

//新增用户路由组
Route::group(['namespace'=>'User'],function (){
    Route::get('login','LoginController@login')->name('login');
    Route::post('login','LoginController@store')->name('login');
    Route::get('logout','LoginController@logout')->name('logout');
    //注册路由
    Route::get('user/register','RegisterController@create')->name('register');
    Route::post('user/register','RegisterController@store')->name('register');
    //重置密码路由
    Route::get('user/resetpassword','ResetPasswordController@index')->name('user.resetpassword');
    Route::post('user/resetpassword','ResetPasswordController@update')->name('user.resetpassword');
});

//用户修改资料路由组
Route::group(['prefix'=>'member','namespace'=>'User','as'=>'user.'],function (){
    Route::resource('info','UserController');
    Route::get('follow/{user}','UserController@follow')->name('follow');
    Route::get('space/home/{user}','SpaceController@home')->name('space.home');
});




Route::group(['prefix'=>'common','namespace'=>'Common','as'=>'common.'],function (){
//公共路由
    Route::any('make','UploadController@make')->name('make');
    Route::any('lists','UploadController@lists')->name('lists');
    Route::any('code','CodeController@send')->name('code');
    //公共方法中的评论路由
    Route::resource('comment','CommentController');
    //网站通知处理路由
    Route::get('notification/{notification}/read','NotificationController@read')->name('notification');
});






